<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateGoodsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('goods', function (Blueprint $table) {
            $table->id();
            $table->integer('sid')->default(0)->comment('商店id');
            $table->integer('aid')->default(0)->comment('创建人id');
            $table->integer('cid')->default(0)->comment('类别id');
            $table->string('name', 512)->default('')->comment('名称');
            $table->string('cover', 256)->default('')->comment('封面');
            $table->text('slide')->comment('轮播');
            $table->text('detail')->comment('详情');
            $table->tinyInteger('status')->default(0)->comment('状态 1 上架 0 下架');
            $table->tinyInteger('pay_type')->default(0)->comment('支付方式 0 现金 1 积分 2 积分+现金');
            $table->integer('views')->default(0)->comment('浏览量');
            $table->integer('weight')->default(1000)->comment('权重');
            $table->integer('min_price')->default(0)->comment('价格下限');
            $table->integer('max_price')->default(0)->comment('价格上限');
            $table->timestamps();
            $table->index('sid');
            $table->index('aid');
            $table->index('cid');
            $table->index('status');
            $table->index('pay_type');
            $table->index('name');
        });
        DB::statement("ALTER TABLE `goods` comment '商品表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('goods');
    }
}
